package com.kun.order.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.kun.order.entity.PaymentEntity;
import com.kun.order.service.PaymentService;
import com.kun.common.utils.PageUtils;
import com.kun.common.utils.R;



/**
 * 
 *
 * @author kun_er
 * @email 2661038743@qq.com
 * @date 2022-05-02 16:08:08
 */
@RestController
@RequestMapping("order/payment")
public class PaymentController {
    @Autowired
    private PaymentService paymentService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = paymentService.queryPage(params);

        return R.ok().put("page", page);
    }
    @GetMapping("getPayTypeList")
    public R getPayTypeList(){
        List<PaymentEntity> list = paymentService.list();
        return R.ok().put("data",list);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") String id){
		PaymentEntity payment = paymentService.getById(id);

        return R.ok().put("payment", payment);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody PaymentEntity payment){
		paymentService.save(payment);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody PaymentEntity payment){
		paymentService.updateById(payment);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody String[] ids){
		paymentService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
